package bma.common.langutil.concurrent;

import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class ScheduledExecutorJava implements ScheduledExecutor {

	private ScheduledExecutorService service;

	public ScheduledExecutorJava() {
		super();
	}

	public ScheduledExecutorJava(ScheduledExecutorService service) {
		super();
		this.service = service;
	}

	public ScheduledExecutorService getService() {
		return service;
	}

	public void setService(ScheduledExecutorService service) {
		this.service = service;
	}

	@Override
	public boolean schedule(Runnable command, long delay, TimeUnit unit) {
		service.schedule(command, delay, unit);
		return true;
	}

	@Override
	public boolean scheduleAtFixedRate(Runnable command, long initialDelay,
			long period, TimeUnit unit) {
		service.scheduleAtFixedRate(command, initialDelay, period, unit);
		return true;
	}

	@Override
	public boolean scheduleWithFixedDelay(Runnable command, long initialDelay,
			long delay, TimeUnit unit) {
		service.scheduleWithFixedDelay(command, initialDelay, delay, unit);
		return true;
	}

}
